package com.app.lxx.pregnancyberth.ui;

import static com.app.lxx.pregnancyberth.ui.VoipP2PActivity.type_load_calllogs;

import android.content.Intent;
import android.graphics.Color;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.app.lxx.pregnancyberth.Mvp.Presenter.CurrencyPresenter;
import com.app.lxx.pregnancyberth.Mvp.View.CurrencyView;
import com.app.lxx.pregnancyberth.R;
import com.app.lxx.pregnancyberth.base.BaseActivity;
import com.app.lxx.pregnancyberth.base.UrlManage;
import com.app.lxx.pregnancyberth.easyphone.EasyLinphone;
import com.app.lxx.pregnancyberth.easyphone.callback.PhoneCallback;
import com.app.lxx.pregnancyberth.easyphone.callback.RegistrationCallback;
import com.app.lxx.pregnancyberth.service.DataBus;
import com.app.lxx.pregnancyberth.ui.entity.CallLogsEntity;
import com.app.lxx.pregnancyberth.ui.entity.EbookWdPtEntity;
import com.app.lxx.pregnancyberth.ui.entity.ScreenSetData;
import com.app.lxx.pregnancyberth.ui.entity.UserInfoEntity;
import com.app.lxx.pregnancyberth.utils.NetUtils;
import com.app.lxx.pregnancyberth.utils.TimeUtil;
import com.app.lxx.pregnancyberth.widge.ChineseToSpeech;
import com.app.lxx.pregnancyberth.widge.LoadDailog.LoadDialog;
import com.app.lxx.pregnancyberth.widge.Recycler.MyRecycleAdapter;
import com.app.lxx.pregnancyberth.widge.SharedPreferencesUtils;
import com.app.lxx.pregnancyberth.widge.UserInfo;
import com.app.lxx.pregnancyberth.widge.uploadimage.WebPhotoActivity;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.google.gson.Gson;

import org.linphone.core.LinphoneCall;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Lxx on PregnancyBerth
 * 2019/8/14 11:25 星期三
 * Details：电子书包 文档播放
 */
public class MyEbookWdPtActivity extends BaseActivity<CurrencyPresenter> implements CurrencyView , View.OnClickListener  {

    private List<EbookWdPtEntity.DataBean> arrayList = new ArrayList<>();
    private String titleString = "";
    private String typeString = "";
    private MyRecycleAdapter myRecycleAdapter;



    private TextView targetidText;
    private View mToggleSpeaker, mToggleMute;
    private ImageView mHangUp, mCallIn;
    private boolean isUpDateStatus = true;//是否需要更新通话状态
    private boolean inComingCall = false;
    private boolean isBusy = false;  //是否正在通话中。true 表示正忙 false 表示为不忙。
    //private boolean isAnswer = false;  //是否正在通话中。true 表示正忙 false 表示为不忙。
    private boolean isCallPhone = false;
    String lastText = "";
    long lastTime = 0;
    CountDownTimer mSpeechTextTimer;
    private ChineseToSpeech chineseToSpeech;
    private View  root_view, calling_view;
    private LinearLayout controlView;
    private View view_front_black;

    private ScreenSetData mScreenSetData;//??

    private long firstPressedTime = 0;
    @Override
    protected void onResume() {
        super.onResume();
        isBusy = false;  //是否正在通话中。true 表示正忙 false 表示为不忙。
    }
    private void initSubcribes() {
        DataBus.unSubscribe("callButton");
        DataBus.unSubscribe("netChanged");
        Log.e("sssssButtonService", "VoipP2PActivity initSubcribes");


        DataBus.subscribe("callButton", new DataBus.Subscriber() {
            @Override
            protected void onReceive(DataBus.Message msg) {
                try {
                    Log.e("sssssButtonService", "VoipP2PActivity onReceive msg="+msg);
                    if (msg.what == 1) {//手柄监听，release版本下才能启用
                        Log.e("sssssButtonService", "VoipP2PActivity CallPhoneIntent");
                        Log.e("sssssButtonServicemsg=1", String.format("isCallPhone:%s,isBusy:%s,isAnswer:%s", isCallPhone, isBusy, "isAnswer"));

                        if (System.currentTimeMillis() - firstPressedTime > 100) {//设置按钮重复按在1秒间隔
                            if (isCallPhone) {
                                if (isBusy) {
                                    // 挂断
                                    calling_view.setVisibility(View.GONE);
                                    hangUp();
                                    isCallPhone = false;
                                    isBusy = false;
                                } else {
                                    // 接听
                                    mCallIn.setVisibility(View.GONE);
                                    calling_view.setVisibility(View.VISIBLE);
                                    acceptCall();
                                    isBusy = true;
                                }
                            } else {
                                try {
                                    audioCall(phoneNumber);
                                    isBusy=true;
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    showToast(e.getMessage());
                                }
                            }
                        } else {
                            firstPressedTime = System.currentTimeMillis();
                        }
                        view_front_black.setVisibility(View.GONE);
                        setDelayTimeToScreen();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        DataBus.subscribe("netChanged", new DataBus.Subscriber() {
            @Override
            protected void onReceive(DataBus.Message msg) {
                try {
                    boolean isConnected = NetUtils.isNetworkConnected(context);
                    Log.e("NetReceiver", "网络状态：" + isConnected);
                    Log.e("NetReceiver", "网络连接类型：" + NetUtils.getConnectedType(context));
                    if (isConnected) {
                        try {
                            EasyLinphone.login();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } else {

                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * 保存呼叫记录 /api/index/addcalllog
     */
    private final int index_addcalllog = 5;
    //语音呼叫//接听状态１接通２未接通3拒接4呼叫保持5取消呼叫
    public void audioCall(String dialNum) {
        isUpDateStatus = false;
        String bindNurseAccount = shareference.getBindNurseUser();
        if (!TextUtils.isEmpty(bindNurseAccount)) {
            phoneNumber = bindNurseAccount;
        }
        if (TextUtils.isEmpty(phoneNumber) || !isHavePeople) {
            showToast("未获取到责任人，请联系医护人员");
            speechText("未获取到责任人,请稍后重试，或联系医护人员");
            requestImfoIndex();
            return;
        }
//        if (isHavePeople) {
        EasyLinphone.callTo(dialNum, false);
        try {
            calling_view.setVisibility(View.VISIBLE);
            targetidText.setText("呼叫中...");
        } catch (Exception e) {
            e.printStackTrace();
        }

        String zrhs = "";//责任护士
        String zrhs_id = "";//责任护士id
        try {
            String hospital_id = maternalData.getMaternal().getHospital_id();//住院号
            String peiHuStatus = maternalData.getMaternal().getPeihu_status();//陪护状态
            String zrys = maternalData.getMaternal().getDoctor().getName();//责任医生
            zrhs = maternalData.getMaternal().getNurse().getName();
            zrhs_id = maternalData.getMaternal().getNurse().getId();
            String zchs = maternalData.getMaternal().getMidwife().getName();//助产士
        } catch (Exception e) {
            e.printStackTrace();
        }

        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("maternal_id", shareference.getUserID());
        String doctor = zrhs_id;//护士id
        hashMap.put("doctor", doctor);
        hashMap.put("callname", UserInfo.UserName);
        hashMap.put("answername", zrhs);
        hashMap.put("from", shareference.getLinPhonDataZh());
        hashMap.put("to", dialNum);
        hashMap.put("call_status", "2");//未接听
        hashMap.put("calltime", TimeUtil.getTimeString());
        getP().requestGet(index_addcalllog, UrlManage.APP_URL + "index/addcalllog", hashMap);

        isCallPhone = true;
    }
    CountDownTimer loadCallLogTimer = null;

    private void stopLoadCallLogTimer() {
        if (loadCallLogTimer != null) {
            loadCallLogTimer.cancel();
        }
    }


    private void startLoadCallLogTimer() {
        CountDownTimer loadCallLogTimer = null;

        if (loadCallLogTimer != null) {
            loadCallLogTimer.cancel();
        }
        new CountDownTimer(1000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                Log.d("ddd", "onTick");
            }

            @Override
            public void onFinish() {
                loadCallLogs();
            }
        }.start();
    }

    private void loadCallLogs() {
        HashMap<String, String> map = new HashMap<>();
        map.put("no", this.shareference.getLinPhonDataZh());
        map.put("call_status", "");
        getP().requestPost(type_load_calllogs, UrlManage.APP_URL + "doctor/newcalllist", map);
    }



    String phoneNumber = "";
    private boolean isHavePeople = true;
    private void requestImfoIndex() {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("house_id", shareference.getUserHouseID()); //	房间id  21
        hashMap.put("bed_id", shareference.getUserBedID());//   	床位id  11

    }


    private void initView() {
        initSubcribes();

        shareference = new SharedPreferencesUtils(MyEbookWdPtActivity.this);
        targetidText =findViewById(R.id.targetid_text);
        mHangUp = findViewById(R.id.hang_up);
        mCallIn = findViewById(R.id.accept_call);
        mToggleSpeaker =  findViewById(R.id.toggle_speaker);
        mToggleMute =  findViewById(R.id.toggle_mute);
        calling_view =  findViewById(R.id.calling_view);

        controlView =  findViewById(R.id.intelligentControl_view);
        root_view =  findViewById(R.id.root_view);
        view_front_black =  findViewById(R.id.view_front_black);

        //设置挂断按钮
        mHangUp.setOnClickListener( MyEbookWdPtActivity.this);
        mCallIn.setOnClickListener( MyEbookWdPtActivity.this);
        initLinPhoneCall();
    }
    private void speechText(String text) {
        Log.e("speechText", "speechText:" + text);
        long time = System.currentTimeMillis();
        if (isBusy || (lastText.equals(text) && time - lastTime < 1000 * 5)) {//通话中 或者间隔不到5秒 或者重复播音  都忽略
            Log.e("speechText", "---ignore speechText:" + text);
            return;
        }
        lastTime = time;
        lastText = text;
        chineseToSpeech.speech(text);
        if (inComingCall) {
            lastText = "";
            lastTime = 0;
            isBusy = false;
            if (mSpeechTextTimer != null) {
                mSpeechTextTimer.cancel();
            }
            mSpeechTextTimer = new CountDownTimer(10 * 1000, 1000) {
                @Override
                public void onTick(long millisUntilFinished) {

                }

                @Override
                public void onFinish() {
                    if (inComingCall) {
                        speechText("护士端呼叫...");
                    }
                }
            }.start();
        }
    }
    private void setDelayTimeToScreen() {
        try {
            long blackScreenTime = 30;//暂定单位为分钟
            if (mScreenSetData != null) {
                blackScreenTime = Long.parseLong(mScreenSetData.getData().getJg_time());
            }
            blackScreenTime = 1;//todo test
            blackScreenTime = System.currentTimeMillis() + blackScreenTime * 60 * 1000;
            view_front_black.setTag(blackScreenTime);
            LogUtils.e("current:" + TimeUtils.millis2String(System.currentTimeMillis()),
                    "close:" + TimeUtils.millis2String(blackScreenTime));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void initLinPhoneCall() {
        chineseToSpeech = new ChineseToSpeech( MyEbookWdPtActivity.this);

        String linPhonDataIp = shareference.getLinPhonDataIp();
        String linPhonDataDq = shareference.getLinPhonDataDq();
        String linPhonDataZh = shareference.getLinPhonDataZh();
        String linPhonDataMm = shareference.getLinPhonDataMm();
        PhoneCallback phoneCallback = new PhoneCallback() {
            @Override
            public void incomingCall(LinphoneCall linphoneCall) {
                // 来电状态
                super.incomingCall(linphoneCall);
                calling_view.setVisibility(View.VISIBLE);
                EasyLinphone.toggleSpeaker(true);
                targetidText.setText("来电中...");
                inComingCall = true;
                speechText("护士端呼叫...");
                mCallIn.setVisibility(View.VISIBLE);
                mHangUp.setVisibility(View.VISIBLE);


                isCallPhone = true;
//                isAnswer = true;
                isBusy = false;
                startLoadCallLogTimer();
                //点亮屏幕
                view_front_black.setVisibility(View.GONE);
                setDelayTimeToScreen();
            }

            @Override
            public void outgoingInit(LinphoneCall linphoneCall) {
                // 呼叫初始化
                super.outgoingInit(linphoneCall);
//                    chineseToSpeech.speech("正在呼叫...");
                inComingCall = false;
                targetidText.setText("呼叫中...");
                speechText("正在呼叫...");
                mHangUp.setVisibility(View.VISIBLE);
                calling_view.setVisibility(View.VISIBLE);
                if (controlView.getVisibility() == View.VISIBLE) {
                    controlView.setVisibility(View.GONE);
                    root_view.setVisibility(View.VISIBLE);
                }

                isCallPhone = true;
//                isAnswer = false;
                isBusy = true;
                view_front_black.setVisibility(View.GONE);
                setDelayTimeToScreen();
            }

            @Override
            public void callConnected(LinphoneCall linphoneCall) {
                // 电话接通
                super.callConnected(linphoneCall);
                inComingCall = false;
                // 视频通话默认免提，语音通话默认非免提
                EasyLinphone.toggleSpeaker(EasyLinphone.getVideoEnabled());
                // 所有通话默认非静音
                EasyLinphone.toggleMicro(false);
                mCallIn.setVisibility(View.GONE);
                mHangUp.setVisibility(View.VISIBLE);
                mToggleSpeaker.setVisibility(View.VISIBLE);
                mToggleMute.setVisibility(View.VISIBLE);
                targetidText.setText("通话中...");
                speechText("已接通...");
                calling_view.setVisibility(View.VISIBLE);
                isBusy = true;
                isCallPhone = true;
            }

            @Override
            public void paused(LinphoneCall linphoneCall) {
                super.paused(linphoneCall);
                inComingCall = false;
                mCallIn.setVisibility(View.GONE);
                mHangUp.setVisibility(View.VISIBLE);
                mToggleSpeaker.setVisibility(View.VISIBLE);
                mToggleMute.setVisibility(View.VISIBLE);
                targetidText.setText("暂停通话...");
                speechText("暂停通话...");
                calling_view.setVisibility(View.VISIBLE);
                isBusy = true;
                isCallPhone = true;
            }

            @Override
            public void Resuming(LinphoneCall linphoneCall) {
                super.Resuming(linphoneCall);
                inComingCall = false;
                mCallIn.setVisibility(View.GONE);
                mHangUp.setVisibility(View.VISIBLE);
                mToggleSpeaker.setVisibility(View.VISIBLE);
                mToggleMute.setVisibility(View.VISIBLE);
                targetidText.setText("通话中...");
                speechText("恢复通话...");
                calling_view.setVisibility(View.VISIBLE);
                isBusy = true;
                isCallPhone = true;
            }

            @Override
            public void callEnd(LinphoneCall linphoneCall) {
                // 电话挂断
                super.callEnd(linphoneCall);
                inComingCall = false;
                speechText("结束通话...");
                calling_view.setVisibility(View.GONE);
                mCallIn.setVisibility(View.GONE);
                mHangUp.setVisibility(View.VISIBLE);
                mToggleMute.setVisibility(View.INVISIBLE);
                mToggleSpeaker.setVisibility(View.INVISIBLE);
                targetidText.setText("结束通话...");
                Log.e("linphone", "callEnd" + linphoneCall);
                isBusy = false;
                isCallPhone = false;
                calling_view.setVisibility(View.GONE);
            }

            @Override
            public void error() {
                super.error();
                speechText("通话异常,请重试...");
                calling_view.setVisibility(View.GONE);
                mCallIn.setVisibility(View.GONE);
                mHangUp.setVisibility(View.VISIBLE);
                mToggleMute.setVisibility(View.INVISIBLE);
                mToggleSpeaker.setVisibility(View.INVISIBLE);
                targetidText.setText("异常结束...");
                Log.e("linphone", "error");
                isBusy = false;
                isCallPhone = false;
            }

            @Override
            public void callReleased(LinphoneCall linphoneCall) {
                super.callReleased(linphoneCall);
                // 电话挂断
                super.callEnd(linphoneCall);
                if (isBusy) {
                    speechText("结束通话...");
                }
                calling_view.setVisibility(View.GONE);
                mCallIn.setVisibility(View.GONE);
                mHangUp.setVisibility(View.VISIBLE);
                mToggleMute.setVisibility(View.INVISIBLE);
                mToggleSpeaker.setVisibility(View.INVISIBLE);
                targetidText.setText("结束通话...");
                Log.e("linphone", "callEnd" + linphoneCall);
                isBusy = false;
                isCallPhone = false;
            }
        };
        EasyLinphone.addCallback(new RegistrationCallback() {
            @Override
            public void registrationOk() {
                super.registrationOk();
                LoadDialog.dismiss(  MyEbookWdPtActivity.this);
                showToast("登录成功！");
            }

            @Override
            public void registrationFailed() {
                LoadDialog.dismiss(  MyEbookWdPtActivity.this);
                super.registrationFailed();
                showToast("登录失败！");
            }

            @Override
            public void registrationProgress() {
                super.registrationProgress();
                LoadDialog.show(  MyEbookWdPtActivity.this, "登录中");
            }

            @Override
            public void registrationNone() {
                super.registrationNone();
            }

            @Override
            public void registrationCleared() {
                super.registrationCleared();
            }
        }, phoneCallback);

        if (TextUtils.isEmpty(linPhonDataIp) || TextUtils.isEmpty(linPhonDataDq) ||
                TextUtils.isEmpty(linPhonDataZh) || TextUtils.isEmpty(linPhonDataMm)) {
            startActivity(new Intent(  MyEbookWdPtActivity.this, ControllerActivity.class));
        } else {
            EasyLinphone.setAccount(linPhonDataZh, linPhonDataMm, linPhonDataIp + ":" + "5060");
            EasyLinphone.login();
        }
    }

    // 点击接听
    public void acceptCall() {
        changeCallStatus("1");
        EasyLinphone.acceptCall();
        isUpDateStatus = false;
    }

    // 挂断
    public void hangUp() {
        if (isUpDateStatus) {
            changeCallStatus("3");
        } else {
//            changeCallStatus("5");
        }
        EasyLinphone.hangUp();
        isBusy = false;
        isCallPhone = false;
        isUpDateStatus = true;
    }
    private String callingLogId = "";
    private final int index_change_call_status = 14;
    private void changeCallStatus(String status) {
        if (TextUtils.isEmpty(callingLogId)) {
            Log.d("callingLogId", "callingLogId:" + callingLogId);
            return;
        }
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("id", callingLogId);
        hashMap.put("call_status", status);
        getP().requestGet(index_change_call_status, UrlManage.APP_URL + "/doctor/editcall", hashMap);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {

            case R.id.btn_closeScreen:
                //息屏
                view_front_black.setVisibility(View.VISIBLE);
                view_front_black.setTag(0);

            case R.id.accept_call:
                // 接听
                mCallIn.setVisibility(View.GONE);
                acceptCall();
                break;
            case R.id.hang_up:
                // 挂断
                calling_view.setVisibility(View.GONE);
                hangUp();
                break;

        }
    }
    

    @Override
    protected CurrencyPresenter createP() {
        return new CurrencyPresenter();
    }

    @Override
    protected void initBindViewId() {
        String ebooktitle = getIntent().getStringExtra("EBOOKTITLE");
        String ebooktype = getIntent().getStringExtra("EBOOKTYPE");

        if (ebooktitle.equals("产前")) {
            titleString = "1";
            if (ebooktype.equals("sp")) {
                typeString = "1";
            } else if (ebooktype.equals("wd")) {
                typeString = "2";
            } else if (ebooktype.equals("ppt")) {
                typeString = "4";
            } else if (ebooktype.equals("tp")) {
                typeString = "3";
            }
        } else if (ebooktitle.equals("产时")) {
            titleString = "2";
            if (ebooktype.equals("sp")) {
                typeString = "1";
            } else if (ebooktype.equals("wd")) {
                typeString = "2";
            } else if (ebooktype.equals("ppt")) {
                typeString = "4";
            } else if (ebooktype.equals("tp")) {
                typeString = "3";
            }
        } else if (ebooktitle.equals("产后")) {
            titleString = "3";
            if (ebooktype.equals("sp")) {
                typeString = "1";
            } else if (ebooktype.equals("wd")) {
                typeString = "2";
            } else if (ebooktype.equals("ppt")) {
                typeString = "4";
            } else if (ebooktype.equals("tp")) {
                typeString = "3";
            }
        }
        requestBagIndex();
        TextView ebook_title = findViewById(R.id.ebook_title);
        ebook_title.setText(ebooktitle);
        RecyclerView myRecyclerInfo = findViewById(R.id.myRecyclerView);
        myRecycleAdapter = new MyRecycleAdapter<EbookWdPtEntity.DataBean>(context,
                arrayList, R.layout.item_myebookwdpt_layout, false) {
            @Override
            protected void setPositionClick(int position) {
                EbookWdPtEntity.DataBean dataBean = arrayList.get(position);
                String file = dataBean.getFiles();
                if (file.contains("doc") || file.contains("docx") || file.contains("xls") || file.contains("xlsx")
                        || file.contains("zip") || file.contains("rar") || file.contains("pdf") || file.contains("PDF")) {
                    startActivity(new Intent(context, ThreeSoftwareActivity.class)
                            .putExtra("uri", urlManage.imageUrl + file));
                } else {
                    startActivity(new Intent(context, WebPhotoActivity.class)
                            .putExtra("uri", urlManage.imageUrl + file));
                }
            }

            @Override
            protected void initData(MyViewHolder holder, final int position) {
                if (position % 2 == 0) {
                    holder.getView(R.id.item_ebook).setBackgroundColor(Color.parseColor("#D4DFFF"));
                } else {
                    holder.getView(R.id.item_ebook).setBackgroundColor(Color.parseColor("#F7F7F7"));
                }
                holder.setText(R.id.ebookwdpt_num, String.valueOf(position + 1));
                holder.setText(R.id.ebookwdpt_name, arrayList.get(position).getTitle());
            }
        };

        myRecyclerInfo.setLayoutManager(utilsManage.linearLayoutManager(context, LinearLayout.VERTICAL, true));
        myRecyclerInfo.setAdapter(myRecycleAdapter);
        initView();

    }

    @Override
    protected boolean hidetitle() {
        return false;
    }

    @Override
    protected String settitle() {
        return "电子书包";
    }

    @NonNull
    @Override
    public int setxmlview() {
        return R.layout.activity_my_ebookwdpt;
    }

    private UserInfoEntity.DataBean maternalData;

    @Override
    public void requestCurrencyView(int type, String body) {
        EbookWdPtEntity ebookWdPtEntity = new Gson().fromJson(body, EbookWdPtEntity.class);
        arrayList.clear();
        arrayList.addAll(ebookWdPtEntity.getData());
        myRecycleAdapter.notifyDataSetChanged();
        switch (type) {

            case type_load_calllogs:

                Log.d("ddd", body);
                CallLogsEntity logEntitys = new Gson().fromJson(body, CallLogsEntity.class);
                if (logEntitys.getCode() == 1) {
                    List<CallLogsEntity.DataBean> logs = logEntitys.getData();
                    for (CallLogsEntity.DataBean log : logs) {
                        String callstatus = log.getCall_status();
                        String id = log.getId();
                        if ("2".equals(callstatus)) {
                            if (shareference.getLinPhonDataZh().equals(log.getTo())) {
                                callingLogId = id;
                                Log.d("call", "找到id:" + callingLogId);
//                                    checkCallingStatus();
                                stopLoadCallLogTimer();
                                return;
                            }
                        }
                    }
                }
                startLoadCallLogTimer();
                break;
        }


    }

    @Override
    public void requestCurrencyViewFailed(int type, int code) {

    }

    private void requestBagIndex() {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("shiduan", titleString);
        hashMap.put("category", typeString);
        if (utilsManage.isNull(hashMap)) {
            // showToast(getString(R.string.message_isnull));
        } else {
            getP().requestGet(1, UrlManage.APP_URL + "index/bag", hashMap);
        }
    }

}